<link rel="stylesheet" type="text/css" href="<?= base_url() ?>file/js/easyui/themes/gray/easyui.css">
<link rel="stylesheet" type="text/css" href="<?= base_url() ?>file/js/easyui/themes/icon.css">

<script type="text/javascript" src="<?= base_url() ?>file/js/add-item.js"></script>
<style>
    .width-80
    {
        width: 80px;
    }
</style>

<form id="form" action="<?=$_SERVER['PHP_SELF']?>" method="post">
<!-- <form id="form" action="<?=base_url()?>index.php/sales_order/save_sales_order" method="post"> -->
<div class="panel-wrap" style="height: auto">
	<div class="panel-header-div">Cluster Information</div>
    <div class="panel-body-div">
    
        <div class="left-panel-body">
        <input type="hidden" id="checkson" value="test"/>
        <!--<div id="textis" style="float: left; width: 100px; height: 100px; background-color: aqua;">
        
        </div>-->
        <?php foreach($cluster as $item):?>
            <h2><?php echo $item->territory_name?></h2>
            <p><?php echo ""?></p>
            <input type="hidden" value="<?php echo $item->territory_id?>" name="territory_id"/>
        <?php endforeach?>
        </div>
        <div class="right-panel-body">
            <table class="table-right-panel" width="100%" border="solid black 1px">
                <tr align="center" class="tr-colour">
                    <th width="50%" align="center">Date</th>
                    <th align="center">Sales Order No</th>
                </tr>
                
                <script type="text/javascript">
				        $(function() {
                            $("#date").datepicker({ dateFormat: 'yy-mm-dd' });
				        });
				</script>
                <tr align="center" class="gray">
                    <td width="50%" align="center"><input type="text" id="date" name="so_date" onclick="this.value='';" value="<? print(Date("Y-m-d")); ?>"/><img height="15px" src="<?= base_url() ?>file/js/easyui/themes/pepper-grinder/images/datebox_arrow.png" /></td>
                    <td align="center">auto generated</td>
                    
                    
                </tr>
            </table>
        </div>
        
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function(){
        $('.day_0').hide();
        $('.day_7').hide();
        $('.day_14').hide();
        $('.day_30').hide();
    });
        var counterTR = 0;
        var total_subtotal = 0;
        var total_discount = parseFloat(0);
        var total_total = parseFloat(0);
        var total_cash_paid = parseFloat(0);
        var get_sales_id = "";

        $(document).ready( function() {
            $("#sales-name").autocomplete({
                minLength: 1,
                source:
                function(req, add){
                    $.ajax({
                        url: "<?php echo base_url(); ?>index.php/sales_order/lookup",
                        dataType: 'json',
                        type: 'POST',
                        data: req,
                        success:
                        function(data){
                            if(data.response =="true"){
                                add(data.message);
                            }
                        },
                    });
                },
            select:
                function(event, ui) {
                    $("#sales-id").val(ui.item.id);
                    populateSalesOrder($("#sales-id").val());
                },
            });

        });
        
        function delete_checked()
        {
            //total_cash_paid = parseFloat(0);
            //alert('hoi');
            
            var find_amount = "";
            
            var value_amount = parseFloat(0);
            
            $('input:checkbox:checked').parent().parent().not('#tr_select_all').each(function(i) {
                find_amount = $(this).find('.amount').attr('id');
                value_amount = $('#'+find_amount).val();
                total_subtotal -= value_amount;
                
                /**find_reseller_disc = $(this).find('.reseller').attr('id');
                value_reseller_disc = $('#'+find_reseller_disc).val();
                total_discount -= value_reseller_disc;  
                
                find_amount = $(this).find('.amount').attr('id');
                value_amount = $('#'+find_amount).val();
                total_total -= value_amount;*/
                //alert('hoi');
            });
            
            $('input:checkbox:checked').parent().parent().not('#tr_select_all').remove();    
            
            $("#subtotal").val(total_subtotal);

            $("#discount").val(total_discount);
            //$("#discount").val(0);

            $("#subtotalDummy").val(CommaFormatted(total_subtotal+'.00'));
            $("#discount").val(0);

            $("#cash_paid").val(total_subtotal);
            $("#total").val(total_subtotal);
            $("#totalDummy").val(CommaFormatted(total_subtotal+'.00'));
            
            
        }

        
        function texy(x, counter)
        {
            $("#iccid"+counter).val(x);
            $('#td_iccid'+counter).empty();
            voila(x,counter);
        }
        
        function autocompletex(x, counter)
        {
            var userid = '';
            $('#td_iccid'+counter).empty();
            $("#"+x).autocomplete({
                minLength: 1,
                source:
                function(req, add){
                    $.ajax({
                        url: "<?php echo base_url(); ?>index.php/sales_order/lookup_iccid",
                        dataType: 'json',
                        type: 'POST',
                        data: req,
                        success:
                        function(data){
                            if(data.response =="true"){
                                add(data.message);
                            }
                        },
                    });
                },
                select:
                function(event, ui) {
                    //alert('tes');
                    userid = $("#sales-id").val();
                    //alert(ui.item.value+" "+counter+" "+ userid);
                    voila(ui.item.value, counter, userid);
                    $("#iccid"+counter).attr("readonly", 'true');
                },
            
            });
        }
        
        
        function voila(x, counter, userid)
        {
            //alert(x + " " + userid)
            $.ajax({
                    url: "<?php echo base_url(); ?>index.php/sales_order/get_iccid_data/"+x+"/"+userid,
                    dataType:"json",
                    success:function(data){
                             //alert('tes');
                             //var text = $('select#iccid'+counter+' option:selected').attr('value');
                             var itemgroup = data['item_group_name'];
                             var itemname = data['item_name'];
                             var default_price = data['f_get_price'];
                             var reseller_price = data['reseller_price'];
                             var mdn = data['mdn'];
                             var partner = data['partner'];


                             $("#itemgroup"+counter).val(itemgroup); 
                             $("#itemname"+counter).val(itemname);
                             $("#default_price"+counter).val(default_price);
                             $("#default_priceDummy"+counter).val(CommaFormatted(reseller_price));
                             $("#reseller_disc"+counter).val(0);
                             $("#mdn"+counter).val(mdn);
                             $("#partner"+counter).val(partner);
                             
                             $("#cash_paid").val(total_cash_paid);  
                             
                             sumPrice(counter);
                    },
                    error: function(data){
                        
                    }
                });
        }
        
        function CommaFormatted(amount)
        {
	       var delimiter = ","; // replace comma if desired
    	   var a = amount.split('.',2);
           // var d = (a[0]) ? var d = 0 : var d = a[0] ;
           if ( a[1] != undefined ) {
    	       var d = a[1];
           }
           else
           {
                var d = 0;
           }
           // alert (a[1]);
	       var i = parseFloat(a[0]);
	       if(isNaN(i)) { return ''; }
	       var minus = '';
	       if(i < 0) { minus = '-'; }
	       i = Math.abs(i);
	       var n = new String(i);
	       var a = [];
	       while(n.length > 3)
	       {
		      var nn = n.substr(n.length-3);
		      a.unshift(nn);
		      n = n.substr(0,n.length-3);
	       }
            if(n.length > 0) { a.unshift(n); }
    	       n = a.join(delimiter);
	           if(d.length < 1) { amount = n; }
	           else { amount = n + '.' + d; }
	           amount = minus + amount;
            return amount;
        }
        
        function sumPrice(counterTR)
        {
            var each_amount = parseFloat(0);
            var each_discount = parseFloat(0);
            var each_price = parseFloat(0);
            var each_subtotal = parseFloat(0);
            var each_priceCurrent = parseFloat(0);
            var checkDisc = $("#reseller_disc"+counterTR).val();
            var x = '';
            
            if(checkDisc < 0 || checkDisc > 100)
            {
                alert('diskon berlebihan');
                $("#reseller_disc"+counterTR).val(0);
            }
            
            $("#subtotal").val(0);
            $("#discount").val(0);
            $("#total").val(0);
            $("#cash_paid").val(0);
            
            
            each_priceCurrent = parseFloat($("#default_priceCurrent"+counterTR).val());
            each_price = parseFloat($("#default_price"+counterTR).val());
            each_discount = parseFloat($("#reseller_disc"+counterTR).val());
            each_amount = each_price - (each_price*each_discount/100);
            // each_amount = each_price - Math.round(each_price*each_discount/100);
            
            $("#amountDummy"+counterTR).val(CommaFormatted(each_amount+'.00'));
            $("#amount"+counterTR).val(each_amount);
            
            total_subtotal = total_subtotal - each_priceCurrent;
            
            total_subtotal += each_amount;
            total_discount += each_discount;
            total_total += each_amount;
            total_cash_paid += each_amount;
            
            $("#subtotal").val(total_subtotal);
            $("#subtotalDummy").val(CommaFormatted(total_subtotal+'.00'));
            //$("#discount").val(total_discount);
            $("#totalDummy").val(CommaFormatted(total_subtotal+'.00'));
            $("#total").val(total_subtotal);
            $("#cash_paid").val(total_subtotal);
            
            
            //each_priceCurrent = each_price;
            $("#default_priceCurrent"+counterTR).val(each_amount);
        }
        
        function sumPrice2(counterTR)
        {
			var each_amount = parseFloat(0);
            var each_discount = parseFloat(0);
            var each_price = parseFloat(0);
            
            //var checkAmount = $("#amountDummy"+counterTR).val();
            //var checkDef = $("#default_price"+counterTR).val();
            
            //if(checkAmount > checkDef)
            //{
                //alert('amount berlebihan');
                
            //}
            
            $("#subtotal").val(0);
            $("#discount").val(0);
            $("#total").val(0);
            
            each_priceCurrent = parseFloat($("#default_priceCurrent"+counterTR).val());
            each_price = parseFloat($("#default_price"+counterTR).val());
            each_amount = parseFloat($("#amountDummy"+counterTR).val());
            each_discount = (each_price - each_amount)/each_price*100;
            // each_discount = Math.round((each_price - each_amount)/each_price*100);
            
            $("#amount"+counterTR).val(each_amount);
            
            var checkAmount = $("#amount"+counterTR).val();
            var checkDef = $("#default_price"+counterTR).val();
            
            if(parseFloat(checkAmount) > parseFloat(checkDef))
            {
                alert('jumlah berlebihan'); 
                $("#amountDummy"+counterTR).val(checkDef);
                each_amount = parseFloat($("#amountDummy"+counterTR).val());  
                each_discount = 0;         
            }                                                            
			
            total_subtotal = total_subtotal - each_priceCurrent;
			
            total_subtotal += each_amount;
            total_total += each_amount;
            
            $("#subtotal").val(total_subtotal);
            $("#subtotalDummy").val(CommaFormatted(total_subtotal+'.00'));
            $("#totalDummy").val(CommaFormatted(total_subtotal+'.00'));
            $("#total").val(total_subtotal);
            
            $("#reseller_disc"+counterTR).val(each_discount);
            $("#default_priceCurrent"+counterTR).val(each_amount);
            
        }
        
        function countTotal()
        {
            var subtotal = $("#subtotal").val();
            var discount = $("#discount").val();
            var total = subtotal - (subtotal * discount/100);
            $("#total").val(total);  
            $("#cash_paid").val(total);
            $("#totalDummy").val(CommaFormatted(total+'.00'));
        }
        
        function populateSalesOrder(sales_id)
        {
            $(".wide").empty();
                $.ajax({
                    url: "<?php echo base_url(); ?>index.php/sales_order/load_sales_order/"+sales_id,
                    dataType:"json",
                    success:function(data){
                    total_cash_paid = 0;
                    total_default_price = 0;
                    $.each(data, function(i,n){

                            add_tuple = "<tr align='center' id='new_tuple"+test+"' class='wide'>"+
                                            "<td><input type='checkbox' id='checkbox"+counterTR+"'/></td>"+
                                            "<td><input type='text' id='partner"+counterTR+"' readonly='true' class='input-readonly' name='partner[]' value='"+ n["partner"] +"'/></td>"+
                                            "<td><input type='text' id='iccid"+counterTR+"' value='"+ n["iccid"] +"' name='iccid[]' onkeyup='autocompletex(this.value,"+counterTR+")' autocomplete='off'/><ul id='td_iccid"+counterTR+"' class='td_iccid'></ul></td>"+
                                            "<td><input type='text' readonly='true' style='border: none; width: 80px;' id='mdn"+counterTR+"' value='"+ n["mdn"] +"' name='mdn[]'</td>"+
                                            "<td><input type='text' id='itemgroup"+counterTR+"' readonly='true' class='input-readonly' name='item_group_name[]' value='"+ n["item_group_name"] +"' /> </td>"+
                                            "<td><input type='text' id='itemname"+counterTR+"' readonly='true' class='input-readonly' name='item_name[]' value='"+ n["item_name"] +"'/></td>"+
                                            "<td><input type='text' class='default_price' id='default_price"+counterTR+"' style='border:none' readonly='true' class='input-readonly' name='default_price[]' value='"+ n["default_price"] +" '/></td>"+
                                            "<td><input type='text' class='reseller' id='reseller_disc"+counterTR+"' name='reseller_disc[]' onchange='sumPrice("+counterTR+")'/></td>"+
                                            "<td><input type='text' class='amount' readonly='true' style='border:none' id='amount"+counterTR+"' name='amount[]'/></td>"+
                                        "</tr>";
                            if (n["top_day"] != 0 ) {
                                $('#table-updateable').append(add_tuple);
                            }
                            test++;
                        });
                    },
                    error: function(data){
                        
                    }
                });               
        }

        $(function(){
            $("#sales-id").change(function(){
                var sf = $('select#sales-id option:selected').attr('class');
                $("#sales-name").val(sf);
                var sales_id = $("#sales-id").val();
                                
                $(".wide").empty();
                $('.day_0').hide();
                $('.day_7').hide();
                $('.day_14').hide();
                $('.day_30').hide();
                $.ajax({
                    url: "<?php echo base_url(); ?>index.php/sales_order/load_sales_order/"+sales_id,
                    dataType:"json",
                    success:function(data){
                    total_subtotal = 0;
                    total_total = 0;
                    total_cash_paid = 0;
                    total_default_price = 0;
                    $.each(data, function(i,n){
                           // alert(sales_id);                        
                            //document.write(n['iccid']);
                            counterTR++;
                            add_tuple = "<tr align='center' id='new_tuple"+test+"' class='wide'>"+
                                            "<input type='hidden' name='scan_in_id' value='"+ n["scan_in_id"] +"' />"+
                                            "<td><input type='checkbox' id='checkbox"+counterTR+"'/></td>"+
                                            "<td><input type='text' id='partner"+counterTR+"' readonly='true' class='input-readonly' name='partner[]' value='"+ n["channel_id"]+" "+n["partner"] +"' /> </td>"+
                                            "<td><input type='text' id='iccid"+counterTR+"' value='"+ n["iccid"] +"' name='iccid[]' style='width: 180px' readonly='readonly' /><ul id='td_iccid"+counterTR+"' class='td_iccid'></ul></td>"+
                                            "<td><input type='text' readonly='true' style='border: none; width: 80px;' id='mdn"+counterTR+"' value='"+ n["mdn"] +"' name='mdn[]'</td>"+
                                            "<td><input type='text' id='itemgroup"+counterTR+"' readonly='true' class='input-readonly' name='item_group_name[]' value='"+ n["item_group_name"] +"' /> </td>"+
                                            "<td><input type='text' id='itemname"+counterTR+"' readonly='true' class='input-readonly' name='item_name[]' value='"+ n["item_name"] +"'/> </td>"+
                                            "<td><input type='hidden' name='default_price[]' value='"+ n["default_price"] +"' id='default_price"+counterTR+"'/>"+
                                            "<input type='text' style='width: 80px; border: none' class='default_price' style='border:none' readonly='true' class='input-readonly' value='"+ CommaFormatted(n["default_price"]) +"'/></td>"+
                                            "<td><input type='text' class='reseller' style='width: 80px;' id='reseller_disc"+counterTR+"' name='reseller_disc[]' value='0' onchange='sumPrice("+counterTR+")'/><input type='hidden' value='0' id='default_priceCurrent"+counterTR+"'/></td>"+
                                            "<td><input type='hidden' class='amount' id='amount"+counterTR+"' name='amount[]'/><input type='text' onchange='sumPrice2("+counterTR+")' style='width: 80px;' id='amountDummy"+counterTR+"'/></td>"+
                                        "</tr>";
                                // $('#table-updateable').append(add_tuple);
                            // alert(n["top_day"]);
                            if(n["top_day"] == 0 ) {
                                $('.day_0').show();
                                $('.day_0').after(add_tuple);
                            } 
                            else if(n["top_day"] == 7 ) {
                                $('.day_7').show();
                                $('.day_7').after(add_tuple);
                            } 
                            else if(n["top_day"] == 14 ) {
                                $('.day_14').show();
                                $('.day_14').after(add_tuple);
                            } 
                            else if(n["top_day"] == 30 ) {
                                $('.day_30').show();
                                $('.day_30').after(add_tuple);
                            } 

                            sumPrice(counterTR);
                            test++;
                        });
                    },
                    error: function(data){
                        
                    }
                });
            });
});


$(function(){
            $("#itemAdd").click(function(){
                counterTR++;
                $.add_tuple = "<tr align='center' id='new_tuple"+counterTR+"' class='wide'>"+
                    "<td><input type='checkbox' id='checkbox"+counterTR+"'/></td>"+
                    "<td><input type='text' id='partner"+counterTR+"' readonly='true' class='input-readonly' name='partner[]' style='font-size: 10px; overflow: auto;' /></td>"+
                    "<td><input type='hidden' name='scan_in_id' value /></td>"
                    "<td><input type='text' id='iccid"+counterTR+"' name='iccid[]' onkeyup='autocompletex(this.id, "+counterTR+")'/></td>"+
                    "<td><input type='text' id='mdn"+counterTR+"' readonly='true' class='input-readonly' name='mdn[]' style='font-size: 10px; overflow: auto;' /></td>"+
                    "<td><input type='text' id='itemgroup"+counterTR+"' readonly='true' class='input-readonly' name='item_group_name[]' style='font-size: 10px; overflow: auto;' /></td>"+
                    "<td><input type='text' id='itemname"+counterTR+"' readonly='true' class='input-readonly' name='item_name[]' style='font-size: 10px; overflow: auto;' /></td>"+
                    "<td><input type='hidden' name='default_price[]' id='default_price"+counterTR+"'/><input type='text' class='default_price' id='default_priceDummy"+counterTR+"' style='border:none' readonly='true' class='input-readonly' /></td>"+
                    "<td><input type='text' class='reseller' id='reseller_disc"+counterTR+"' name='reseller_disc[]' onchange='sumPrice("+counterTR+")'/><input type='hidden' value='0' id='default_priceCurrent"+counterTR+"'/></td>"+
                    "<td><input type='hidden' class='amount' id='amount"+counterTR+"' name='amount[]'/><input type='text' readonly='true' style='border:none' id='amountDummy"+counterTR+"' /></td>"+
                "</tr>";
            
                $('#table-updateable').append($.add_tuple);
            
                var copyval = $('#reseller_price'+counterTR).attr('value');
                $("#default_price"+counterTR).val(copyval); 
            
            });
});

    //Pada saat input ICCID, jika tombol "Enter" ditekan -> doNothing
    $('#form').bind("keypress", function(e) {
        if (e.keyCode == 13) {
            return false;
       }
    });
</script>


<div class="panel-wrap" style="height: auto">
	<div class="panel-header-div">Order Information</div>
    
    <div class="panel-body-div">
        <div class="child-panel-body">
        <div class="left-panel-body">
        
            <table class="table-right-panel" width="60%" border="solid black 1px">
                <tr align="center" class="tr-colour2">
                    <th width="20%" align="center">Sales ID</th>
                    <th align="center">Sales Name</th>
                </tr>
                
                
                <tr align="center" class="gray">
                    <td>
                        
                        <select name="sales_id" id="sales-id">
						<option value="">--Select Sales Id--</option>
                            <?php 
                                //edited by alfin akhret
                                if($this->session->userdata('is_self_service') == 1)
                                { 
                                    foreach($sales as $item):
                                        if ($item->user_id == $this->session->userdata('username'))
                                        {                   
                                    ?>
                                            <option value="<?php echo $item->user_id?>"><?php echo $item->user_id .' | '.$item->user_group_caption.' | '. $item->user_name?></option>
                                    <?php
                                        }
                                    endforeach;
                                }
                                else
                                {
                                    foreach($sales as $item):               
                                    ?>
                                            <option value="<?php echo $item->user_id?>"><?php echo $item->user_id .' | '.$item->user_group_caption.' | '. $item->user_name?></option>
                                    <?php

                                    endforeach;
                                }

                                ?>
                        </select>
                        
                    </td>
                    <td class="readonly" align="center">
                        <input  type="text" name="sales_name" id="sales-name" class="width-270"/>
                        
                    </td>
                    
                    
                </tr>
            </table>
        </div>
        <div class="right-panel-body">
            <table class="table-right-panel" width="50%" border="solid black 1px" style="float: right;">
                <tr align="center" class="tr-colour2">
                    <th width="50%" align="center">Payment Method</th>
                    
                </tr>
                
                
                <tr align="center" class="gray">
                    <td width="90%" align="center">
                        <select style="width: 90%;" name="dListPaymentMethod">
                            <?php foreach($payment_method as $method):?>
                                <option value="<?php echo $method->member_display?>">cash</option>
                            <?php endforeach?>
                        </select>
                    </td>
                    
                    
                </tr>
            </table>
        </div>
    </div>
    <div class="child-panel-body-2">
        <div class="buttons">
                <input type="button" id="itemAdd"  value="Add"/> 
                <input type="button" onclick="delete_checked()" value="Delete" />
        </div>
        
        
    </div>
    
    
    <div class="child-panel-body">
        <div style="float: left; width: 100%;">    
             <table class="table-right-panel" id="table-updateable" width="92%" style="margin-left: 19px;">
                <tr align="center" class="tr-colour3" id="tr_select_all">
                    <th><input type="checkbox" id="select_all" onclick="check_all()"/></th>
                    <th>Partner</th>
                    <th>ICCID</th>
                    <th>MDN</th>
                    <th>Item Group</th>
                    <th>Description</th>
                    <th>Price (Rp.)</th>
                    <th>Discount(%)</th>
                    <th>Amount (Rp.)</th>
                    
                </tr>
                
                <tr class="day_0 termin" style="background-color: #dddddd; align: left">
                    <td colspan="9">Pembayaran Cash</td>
                </tr>
                <tr class="day_7 termin" style="background-color: #dddddd; align: left">
                    <td colspan="9">Pembayaran Termin 7 Hari</td>
                </tr>
                <tr class="day_14 termin" style="background-color: #dddddd; align: left">
                    <td colspan="9">Pembayaran Termin 14 Hari</td>
                </tr>
                <tr class="day_30 termin" style="background-color: #dddddd; align: left">
                    <td colspan="9">Pembayaran Termin 30 Hari</td>
                </tr>
                
            </table> 

            <div style="margin-left: 19px; width: 92%">
            <div class="summary" style="float:  right;">
                <table width="100%">
                    <tr>
                        <td>Subtotal</td>
                        <td><input type="hidden" id="subtotal" name="subtotal"/><input type="text" id="subtotalDummy" readonly="true"/></td>
                    </tr>
                    <tr>
                        <td>Discount(%)</td>
                        <td><input type="text" name="discount_total" id="discount" class="discount" onchange="countTotal()"/></td>
                    </tr>
                    <tr>
                        <td>Total</td>
                        <td>
                            <input type="hidden" name="cash_paid" id="cash_paid" readonly="true"/>
                            <input type="hidden" name="total" id="total" readonly="true"/>
                            <input type="text" id="totalDummy" readonly="true"/>
                        </td>
                    </tr>
                    
                    
                </table>
            </div>
            </div>
    </div>
    
    <div class="child-panel-body-2">
        <table class="table-right-panel" width="92%" style="margin-left: 19px; border: none; float: left; margin-top: 20px; margin-bottom: 20px;">
            <tr style="height: 15px;">
                <td style="text-align: left; font-weight: bold; font-size: 1.3em;">Remark:</td>
                <td width="94%" style="border-bottom: solid #000 1px;"><input type="text" name="remark" style="width: 100%; border: none"/></td>
            </tr>
        </table>
    </div>
    
        <div class="child-panel-body-2">
        
            <div class="buttons-2" style="margin: 0 auto">
                <input type="submit" value="Submit"/>
                <input type="button" value="Revert" onclick="window.location.reload(true);"/>
            </div>
            
            
    </div>
    </div>
    </div>
    
</div>
</form>

<script type="text/javascript">
    $(document).ready(function() 
        {
            $("#select_all").click(function() 
            { 
                var checked_status = this.checked; 
                $("input[@name=checkbox]").each(function() 
                { 
                    this.checked = checked_status; 
                }); 
            });
        });            
</script>